<template>
  <div class="nav-bar">
    <div class="left" @click="goBack">
      <i class="iconfont icon-back"><</i>
    </div>
    <div class="center">
      <h1>{{ pageTitle }}</h1>
    </div>
    <div class="right" @click="goToRegister">
      去注册
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';

export default defineComponent({
  name: 'NavBar',
  props: {
    pageTitle: {
      type: String,
      required: true,
    },
  },
  methods: {
    goBack() {
      // 实现返回逻辑，例如使用 router.back()
      console.log('Go back');
    },
    goToRegister() {
      // 实现跳转到注册页面的逻辑
      console.log('Go to register');
    },
  },
});
</script>

<style scoped>
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: #f9a825; /* 黄色背景 */
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 添加阴影效果 */
}

.left .icon-back {
  font-size: 24px;
  cursor: pointer;
  color: white; /* 图标颜色 */
}

.center h1 {
  margin: 0;
  font-size: 20px;
  font-weight: bold; /* 加粗标题 */
}

.right {
  cursor: pointer;
  color: white; /* 右侧文字颜色 */
  font-size: 16px;
  transition: color 0.3s ease; /* 平滑过渡效果 */
}

.right:hover {
  color: #ffffff; /* 鼠标悬停时的文字颜色 */
  text-decoration: underline; /* 鼠标悬停时下划线 */
}
</style>